/*******************************************************************
 *
 * Copyright (C), 2021-2022, LS, All rights reserved.
 *
 * Author      : 
 * Create Time : 2020-12-17
 * Version     : v0.1
 * Description : 
 *******************************************************************/
#ifndef _APP_DISPLAY_H_
#define _APP_DISPLAY_H_
 
/*----------------------------Head file----------------------------*/
#include "stdint.h"
#include "stdbool.h"
#include "hal_display.h"

/*----------------------------macro file---------------------------*/
#define app_disp_backlight_set			hal_disp_backlight_set
#define app_disp_init_state_get			hal_disp_init_state_get

#define SEG_A   0x80
#define SEG_B   0x02
#define SEG_C   0x01
#define SEG_D   0x10
#define SEG_E   0x40
#define SEG_F   0x20
#define SEG_G   0x04

#define SEG_A_0   0x08
#define SEG_B_0   0x20
#define SEG_C_0   0x10
#define SEG_D_0   0x01
#define SEG_E_0   0x04
#define SEG_F_0   0x02
#define SEG_G_0   0x40

#define SEG_A_1   0x01
#define SEG_B_1   0x40
#define SEG_C_1   0x80
#define SEG_D_1   0x08
#define SEG_E_1   0x02
#define SEG_F_1   0x04
#define SEG_G_1   0x20


#define CHAR_NULL   0xFF
/*#define CHAR_0  (SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F)
#define CHAR_1  (SEG_B | SEG_C)
#define CHAR_2  (SEG_A | SEG_B | SEG_G | SEG_E | SEG_D)
#define CHAR_3  (SEG_A | SEG_E | SEG_G | SEG_C | SEG_D)
#define CHAR_4  (SEG_F | SEG_G | SEG_E | SEG_C)
#define CHAR_5  (SEG_A | SEG_F | SEG_G | SEG_C | SEG_D)
#define CHAR_6  (SEG_A | SEG_F | SEG_E | SEG_D | SEG_C | SEG_G)
#define CHAR_7  (SEG_A | SEG_B | SEG_C)
#define CHAR_8  (SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F | SEG_G)
#define CHAR_9  (SEG_A | SEG_F | SEG_G | SEG_B | SEG_C | SEG_D)
#define CHAR_A  (SEG_A | SEG_B | SEG_C | SEG_E | SEG_F | SEG_G)
#define CHAR_C  (SEG_A | SEG_F | SEG_E | SEG_D)
#define CHAR_F  (SEG_A | SEG_F | SEG_G | SEG_E | SEG_D)
#define CHAR_P  (SEG_A | SEG_B | SEG_G | SEG_F | SEG_E)
#define CHAR_L  (SEG_F | SEG_E | SEG_D)	
#define CHAR_o  (SEG_G | SEG_E | SEG_D | SEG_C)
#define CHAR_d  (SEG_B | SEG_C | SEG_G | SEG_E | SEG_D)
#define CHAR_N  (SEG_E | SEG_F | SEG_A | SEG_B | SEG_C)
#define CHAR_E  (SEG_A | SEG_F | SEG_G | SEG_E | SEG_D)*/

#define NUM_MASK1   0x08
#define NUM_MASK2   0x01


/*----------------------------type define--------------------------*/
enum {
    NUM_NO_1 = 0,
    NUM_NO_2,
    NUM_NO_3,
    NUM_NO_4,
    NUM_NO_5,
    NUM_NO_6,
    NUM_NO_7,
    NUM_NO_8,
};


enum {
    SEG_CHAR_0 = 0,
    SEG_CHAR_1,
    SEG_CHAR_2,
    SEG_CHAR_3,
    SEG_CHAR_4,
    SEG_CHAR_5,
    SEG_CHAR_6,
    SEG_CHAR_7,
    SEG_CHAR_8,
    SEG_CHAR_9,
    SEG_CHAR_A,
    SEG_CHAR_C,
    SEG_CHAR_F,
    SEG_CHAR_P,
    SEG_CHAR_L,
    SEG_CHAR_o,
    SEG_CHAR_d,
    SEG_CHAR_N,
    SEG_CHAR_E,
    SEG_CHAR_MINUS,
    
    SEG_CHAR_MAX,
};

enum {
    ICON_BT = 0,
    ICON_BAT0,
    ICON_BAT1,
    ICON_BAT2,
    ICON_BAT3,
    ICON_MODE_FREE,
    ICON_MODE_COUNTDOWN_NUM,
    ICON_MODE_COUNTDOWN_TIME,
    //ICON_SKIP_CNT,
    //ICON_SKIP_TIME,
    ICON_DOT_MINS,
    ICON_DOT_SECS,
    ICON_MAX,
};

typedef struct{
    uint8_t seg1;
    uint8_t seg2;
}num_seg_t;

typedef struct{
    uint8_t seg_num;
    uint8_t mask;
}icon_seg_t;

/*----------------------------var define---------------------------*/

/*-------------------------func declaration------------------------*/
extern void app_disp_update(void);
extern void app_disp_init(void);
extern void app_disp_deinit(void);
extern void app_disp_all_pixel(void);
extern void app_disp_clear(void);

extern void app_disp_icon_set(uint8_t icon);
extern void app_disp_icon_clear(uint8_t icon);

extern void app_disp_burn_ing(void);
extern void app_disp_sn(uint8_t *sn, uint8_t len);
extern void app_disp_done(void);
extern void app_disp_pass(void);
extern void app_disp_fail(void);
extern void app_disp_ota_ing(uint8_t cnt);
extern void app_disp_batt_lo(void);
extern void app_disp_bt_icon(void);
extern void app_disp_batt_icon(void);
extern void app_disp_skip_data(void);
extern void app_disp_charge_state(bool clear);
extern void app_disp_batt_state(uint8_t level);
extern void app_disp_ble_icon_flash(bool reset);
extern void app_disp_low_bat_icon_flash(bool reset);
extern void app_disp_skip_data_flash(uint8_t time_cnt);
extern void app_disp_cnt_down_start_secs(uint16_t num);

extern void app_disp_loop(bool reset);

/*-----------------------------------------------------------------*/


#endif


